<extend name="default/template/base_scoreshop" />

<block name="head">
    <link rel="stylesheet" href="__CSS__/scoreshop_detail.css?v="/>
</block>

<block name="body">
<div class="content-top border-bottom">
    <img src="{:getImageUrl($entry['main_img'],0,1)}">
    <span class="money">{$entry.score}</span>
    <span class="price">萌币<gt name="entry.price" value="0">+￥</gt></span>
    <gt name="entry.price" value="0"><span class="money">{$entry.price}</span></gt>
    <gt name="post_price" value="0"><span class="price">+￥</span><span class="money">{$post_price}</span><span class="price">(邮费)</span></gt>
    <if condition="$entry.count gt 1"><span class="price">&nbsp;&nbsp;剩余</span><span class="money">{$entry.count}</span><elseif condition="$entry.count eq 0" /><span class="money">已兑完</span></if>
    <span class="price"><if condition="$entry.buy_limit gt 0"><span class="price">限兑</span><span class="money">{$entry.buy_limit}</span></if></span>
</div>
<article class="content-mid">{$entry.detail|htmlspecialchars_decode}</article>
<article class="explain">
   {$entry.synopsis|htmlspecialchars_decode}
   <span class="explain-span">说明</span>
</article>
<div class="content">
    <div class="left">单价 ：萌币<span class="money">{$entry.score}</span> <gt name="entry.price" value="0"> +￥<span class="money">{$price}</span></gt> </div>
    <div class="right am-btn am-btn-radius exchange" data-url="{:U('ScoreGoods/exchange',array('uid'=>$uid,'psw'=>$psw,'pid'=>$entry['id'],'paycheck'=>$paycheck))}">立即兑换</div>
</div>
<div class="am-modal am-modal-confirm" tabindex="-1" id="myconfirm">
  <div class="am-modal-dialog">
    <!-- <div class="am-modal-hd"></div> -->
    <div class="am-modal-bd">确定兑换{$entry.name}？</div>
    <div class="am-modal-footer">
      <span class="am-modal-btn" data-am-modal-cancel>取消</span>
      <span class="am-modal-btn" data-am-modal-confirm>确定</span>
    </div>
  </div>
</div>
<!-- alert -->
<div class="am-modal am-modal-alert" tabindex="-1" id="myalert">
  <div class="am-modal-dialog">
    <!-- <div class="am-modal-hd"></div> -->
    <div class="am-modal-bd"></div>
    <div class="am-modal-footer">
      <span class="am-modal-btn " data-am-modal-confirm>确定</span>
    </div>
  </div>
</div>
<!-- alert end -->
<script>
$(function(){
    var progress = $.AMUI.progress,click = true;
    $('.exchange').on('click', function() {
        if(click){
            click = false;
            var url = $(this).data('url');
            // console.log(url);
            $('#myconfirm').modal({
                closeViaDimmer: 0,
                relatedTarget: this,
                onConfirm: function(options) {
                    progress.start();
                    $.getJSON(url,function (data) {
                        click = true;
                        // alert(data);
                        progress.done();
                        if(!data || !data.status){
                            myalert(data.info);
                        }else{
                            // $('#myalert').modal({
                               // relatedTarget: this,
                               // onConfirm:function(options){
                                self.location = data.info;
                               // }
                            // })
                        }
                    });
                },
                // closeOnConfirm: false,
                onCancel: function() {
                    click = true;
                }
            });
            // .on('closed.modal.amui', function() {
            //   click = true;
            // });
        }
    });
    function myalert(con,ele){
        if(!ele) ele='myalert';
        if(!con) con='';
        $('#'+ele).find('.am-modal-bd').html(con)
        .end().modal();
    }
})
</script>
</block>